package entity;

import java.util.Date;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;



@Entity
@Table(name = "prog_comment")
public class Comment {

	private Long id;
	private String text;
	private Date commentdate;
	private Post post;
	
	public Comment() {
		
	}

	public Comment(String text, Date commentdate) {
		super();
		this.text = text;
		this.commentdate = commentdate;
	}

	public Comment(String text, Date commentdate, Post post) {
		super();
		this.text = text;
		this.commentdate = commentdate;
		this.post = post;
	}
	
	@Id
	@SequenceGenerator(name = "Comment_gen", sequenceName = "Comment_index")
	@GeneratedValue(generator = "Comment_gen", strategy = GenerationType.SEQUENCE)
	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public String getText() {
		return text;
	}

	public void setText(String text) {
		this.text = text;
	}

	public Date getCommentdate() {
		return commentdate;
	}

	public void setCommentdate(Date commentdate) {
		this.commentdate = commentdate;
	}
	@ManyToOne(cascade = CascadeType.ALL)
	@JoinColumn(name = "fk_commentid")
	public Post getPost() {
		return post;
	}

	public void setPost(Post post) {
		this.post = post;
	}

}
